package com.sixth.bean.vo;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import org.apache.ibatis.annotations.Case;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author ljh
 * @version 1.0
 * @describition:
 * @since 2022/9/9 20:45
 **/
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class WXOrderListVO {

    /* orderStatusText : 已发货
     * aftersaleStatus : 0
     * isGroupin : false
     * orderSn : 20220909791214
     * actualPrice : 9989.0
     * goodsList : [{"number":1,"picUrl":"http://182.92.235.201:8083/wx/storage/fetch/cqjbdi5bngen9u5cbm6h.jpg","price":9999,"id":123,"goodsName":"AaliyahTestGoods","specifications":["规格值"]}]
     * id : 114
     * handleOption : {"cancel":false,"delete":false,"pay":false,"comment":false,"confirm":true,"refund":false,"rebuy":false,"aftersale":false}
     */

    private String orderStatusText;
    private int aftersaleStatus;
    private boolean isGroupin;
    private String orderSn;
    private BigDecimal actualPrice;
    private int id;
    private HandleOptionBean handleOption = new HandleOptionBean();
    private List<GoodsListBean> goodsList;


    //根据状态码赋值中文状态，以及提供哪些可操作按钮
    public void setOrderStatusText(Integer orderStatusText) {
       switch (orderStatusText){
           case 101: this.orderStatusText = "未付款";
                    this.handleOption.setPay(true);
                    this.handleOption.setCancel(true);
                    break;
           case 102:
                this.orderStatusText = "用户取消";
                this.handleOption.setCancel(true);break;
           case 103: this.orderStatusText = "系统取消";
               this.handleOption.setCancel(true);break;
           case 201: this.orderStatusText = "已付款";
                this.handleOption.setRefund(true);break;
           case 202: this.orderStatusText = "申请退款";break;
           case 203: this.orderStatusText = "已退款";break;
           case 301: this.orderStatusText = "已发货";
                this.handleOption.setConfirm(true);break;
           case 401: this.orderStatusText = "用户收货";
               this.handleOption.setComment(true);
               this.handleOption.setRebuy(true);
               this.handleOption.setAftersale(true);
               break;
           case 402: this.orderStatusText = "系统收货";
               this.handleOption.setComment(true);
               this.handleOption.setRebuy(true);
               this.handleOption.setAftersale(true);break;
           case 403: this.orderStatusText = "已评价";
               this.handleOption.setRebuy(true);
               this.handleOption.setAftersale(true);
               break;

       }
    }

    public void setGroupin(BigDecimal groupin) {
        if(BigDecimal.ZERO.equals(groupin)){
            this.isGroupin = false;
        }else{
            this.isGroupin = true;
        }
    }

}

